"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CommonTools = void 0;
var FGuiType;
(function (FGuiType) {
    FGuiType["GButton"] = "GButton";
    FGuiType["GComboBox"] = "GComboBox";
    FGuiType["GComponent"] = "GComponent";
    FGuiType["GGraph"] = "GGraph";
    FGuiType["GGroup"] = "GGroup";
    FGuiType["GImage"] = "GImage";
    FGuiType["GLabel"] = "GLabel";
    FGuiType["GList"] = "GList";
    FGuiType["GLoader"] = "GLoader";
    FGuiType["GLoader3D"] = "GLoader3D";
    FGuiType["GMovieClip"] = "GMovieClip";
    FGuiType["GProgressBar"] = "GProgressBar";
    FGuiType["GRichTextField"] = "GRichTextField";
    FGuiType["GScrollBar"] = "GScrollBar";
    FGuiType["GSlider"] = "GSlider";
    FGuiType["GTextField"] = "GTextField";
    FGuiType["GTextInput"] = "GTextInput";
    FGuiType["Transition"] = "Transition";
    FGuiType["Controller"] = "Controller";
})(FGuiType || (FGuiType = {}));
class CommonTools {
    static customPropsData;
    /**
     * 是否是 Fgui 的类型
     * @param type
     * @returns
     */
    static checkIsFguiType(type) {
        return type in FGuiType;
    }
    static getCustomPropertyData() {
        if (!this.customPropsData)
            this.customPropsData = CS.FairyEditor.App.project.GetSettings("CustomProperties");
        return this.customPropsData;
    }
    /**
     * 获取项目的自定义属性
     * @param key
     * @returns
     */
    static getCustomSetKeyValue(key) {
        let dic = this.getCustomPropertyData();
        let data = dic.elements.ContainsKey(key) ? dic.elements.get_Item(key) : undefined;
        if (data == undefined) {
            console.log(`未找到 ${key} 的配置项，请检查项目的自定义属性中是否有配置`);
        }
        return data;
    }
    /**
     * 判断是否是需要生成到 ViewID中的ui 组件
     * @param uiName
     */
    static checkIsViewUI(uiName) {
        return uiName.endsWith("View");
    }
    /** UIPkg  ts脚本的保存路径 */
    static getUIPkgPath(exportCodePath) {
        let outPath = "";
        let ctPath = this.getCustomSetKeyValue("UIPkgScriptPath");
        if (ctPath) {
            let idx = exportCodePath.indexOf(`..\\`);
            if (idx > 0) {
                outPath = exportCodePath.substring(0, idx) + ctPath;
            }
        }
        else {
            outPath = exportCodePath + '/' + 'UIPkg.ts';
        }
        return outPath;
    }
    /** UIConst  ts脚本的保存路径 */
    static getUIConstPath(exportCodePath) {
        let outPath = "";
        let ctPath = this.getCustomSetKeyValue("UIConstScriptPath");
        if (ctPath) {
            let idx = exportCodePath.indexOf(`..\\`);
            if (idx > 0) {
                outPath = exportCodePath.substring(0, idx) + ctPath;
            }
        }
        else {
            outPath = exportCodePath + '/' + 'UIConst.ts';
        }
        return outPath;
    }
    /**获取生成的 UIConst 文件中的 import 导入对应的 ts脚本的路径 */
    static getUIConstImportPath() {
        let path = this.getCustomSetKeyValue("BinderImportPath");
        if (path) {
            return path;
        }
        else {
            return "";
        }
    }
    /** ViewId  ts脚本的保存路径 */
    static getViewIdPath(exportCodePath) {
        let outPath = "";
        let ctPath = this.getCustomSetKeyValue("ViewIDScriptPath");
        if (ctPath) {
            let idx = exportCodePath.indexOf(`..\\`);
            if (idx > 0) {
                outPath = exportCodePath.substring(0, idx) + ctPath;
            }
        }
        else {
            outPath = exportCodePath + '/' + 'ViewID.ts';
        }
        return outPath;
    }
}
exports.CommonTools = CommonTools;
